
#include "Mapper004.h"
#include "Cart.h"
#include "NES.h"
#include "MMC3.h"

SETUP_STATIC_INES_MAPPER_REGISTRAR(4)

//------------------------------------------------------------------------------
// Name: Mapper4
//------------------------------------------------------------------------------
Mapper4::Mapper4() : mapper_(
	(nes::cart.rom_hash() == 0xf312d1de ||
	 nes::cart.rom_hash() == 0xa512bdf6 ||
	 nes::cart.rom_hash() == 0x633afe6f ||
	 nes::cart.rom_hash() == 0x1335cb05
	 ) ? static_cast<Mapper *>(new MMC3A) : static_cast<Mapper *>(new MMC3B)) {
}

//------------------------------------------------------------------------------
// Name: ~Mapper4
//------------------------------------------------------------------------------
Mapper4::~Mapper4() {
	delete mapper_;
}

//------------------------------------------------------------------------------
// Name: name
//------------------------------------------------------------------------------
std::string Mapper4::name() const {
	return "Nintendo MMC3/MMC6";
}

//------------------------------------------------------------------------------
// Name: read_6
//------------------------------------------------------------------------------
uint8_t Mapper4::read_6(uint16_t address) {
	return mapper_->read_6(address);
}

//------------------------------------------------------------------------------
// Name: read_7
//------------------------------------------------------------------------------
uint8_t Mapper4::read_7(uint16_t address) {
	return mapper_->read_7(address);
}

//------------------------------------------------------------------------------
// Name: write_6
//------------------------------------------------------------------------------
void Mapper4::write_6(uint16_t address, uint8_t value) {
	mapper_->write_6(address, value);
}

//------------------------------------------------------------------------------
// Name: write_7
//------------------------------------------------------------------------------
void Mapper4::write_7(uint16_t address, uint8_t value) {
	mapper_->write_7(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper4::write_8(uint16_t address, uint8_t value) {
	mapper_->write_8(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper4::write_a(uint16_t address, uint8_t value) {
	mapper_->write_a(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper4::write_c(uint16_t address, uint8_t value) {
	mapper_->write_c(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper4::write_e(uint16_t address, uint8_t value) {
	mapper_->write_e(address, value);
}

//------------------------------------------------------------------------------
// Name:
//------------------------------------------------------------------------------
void Mapper4::vram_change_hook(uint16_t vram_address) {
	mapper_->vram_change_hook(vram_address);
}
